package com.atguigu.c_get;

import java.util.Scanner;

/*
    键盘录入一个字符串,获取这个字符串中 英文大写,英文小写,数字,其他字符出现的个数
 */
public class Test {
    public static void main(String[] args) {
        //键盘录入字符串
        System.out.println("请您输入一个字符串 : ");
        String line = new Scanner(System.in).nextLine();

        //定义统计变量
        int bigCount = 0;
        int smallCount = 0;
        int numCount = 0;
        int otherCount = 0;

        //遍历字符串
        for (int i = 0; i < line.length(); i++) {
            //依次获取每一个索引位置的字符
            char ch = line.charAt(i);
            //判断ch是什么
            if (ch >= 'a' && ch <= 'z'){
                smallCount++;
            } else if (ch >= 'A' && ch <= 'Z'){
                bigCount++;
            } else if (ch >= '0' && ch <= '9') {
                numCount++;
            } else {
                otherCount++;
            }
        }

        System.out.println("bigCount = " + bigCount);
        System.out.println("smallCount = " + smallCount);
        System.out.println("numCount = " + numCount);
        System.out.println("otherCount = " + otherCount);
    }
}
